<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class SocialLoginSecondRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'phone' => 'required|unique:users|regex:/^1[34578][0-9]{9}$/',
            'sms_code' => 'required',
            'password' => 'required|min:6',
            'security' => 'required|min:6',
            'unionID' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'phone.required' => '手机号必须',
            'phone.unique' => '该手机号已注册',
            'phone.regex' => '手机号格式不正确',
            'password.required' => '请输入密码',
            'password.min' => '密码至少6位',
            
            'sms_code.required' => '缺少参数sms_code',

            'security.required' => '请输入交易密码',           
            'security.min' => '交易密码至少6位',
            // 'openid.required' => '缺少参数openid',
            'unionID.required' => '缺少参数unionID',
        ];
    }

}
